Ext.define('PJ.view.myPersonalFiles.List', {
    extend: 'AM.default.DefaultList',
    selModel: {
    },
    requires: ['AM.default.DefaultDateField', 
               'AM.default.DateTime', 
               'AM.default.DefaultSearchForm',
               'AM.default.jsonp.DefaultLoadJsonp',//jsonp加载数据
               'PJ.view.myPersonalFiles.ParticipateClassList'
               ],
               
    //报名管理列表--中组部，部委
               
    initComponent: function(){
        var me = this;
        me.columns = [{
            header: '年份',
            flex:1,
            dataIndex: 'hourYear'
        },{
            header: '中组部调训',
            dataIndex: 'zhongydxHour',
            renderer: function(value, metaData, record){
            	if(value!=0)
            		metaData.style = "white-space:normal;cursor: pointer;color:blue;";
            	metaData.tdAttr = "data-qtip='" + value + 
    			"' hourYear=" + record.get("hourYear");
                return value;
            },
            listeners: {
    			click: function(g, clm){
    				var hourYear = clm.getAttribute("hourYear");
    				var params=g.up().store.proxy.extraParams;
    				Ext.create('AM.default.DefaultWindowView', {
                        title: "查看班级列表",
                        hourYear:hourYear,
                        params:params,
                        searchClassType:'zhongydx',
                        width: 1000,
                        height: 450,
                        items: [{
                        	xtype: 'myPersonalFilesClassList'
                        }]
                    }).show();
    			}
    		}
        },{
            header: '主体班',
            dataIndex: 'zhutbHour',
            renderer: function(value, metaData, record){
            	if(value!=0)
            		metaData.style = "white-space:normal;cursor: pointer;color:blue;";
            	metaData.tdAttr = "data-qtip='" + value + 
    			"' hourYear=" + record.get("hourYear");
                return value;
            },
            listeners: {
    			click: function(g, clm){
    				var hourYear = clm.getAttribute("hourYear");
    				var params=g.up().store.proxy.extraParams;
    				Ext.create('AM.default.DefaultWindowView', {
                        title: "查看班级列表",
                        hourYear:hourYear,
                        params:params,
                        searchClassType:'zhutb',
                       width: 1000,
                        height: 450,
                        items: [{
                        	xtype: 'myPersonalFilesClassList'
                        }]
                    }).show();
    			}
    		}
        },{
            header: '境外培训',
            dataIndex: 'jwpxHour',
            renderer: function(value, metaData, record){
            	if(value!=0)
            		metaData.style = "white-space:normal;cursor: pointer;color:blue;";
            	metaData.tdAttr = "data-qtip='" + value + 
    			"' hourYear=" + record.get("hourYear");
                return value;
            },
            listeners: {
    			click: function(g, clm){
    				var hourYear = clm.getAttribute("hourYear");
    				var params=g.up().store.proxy.extraParams;
    				Ext.create('AM.default.DefaultWindowView', {
                        title: "查看班级列表",
                        hourYear:hourYear,
                        params:params,
                        searchClassType:'jwpx',
                        width: 1000,
                        height: 450,
                        items: [{
                        	xtype: 'myPersonalFilesClassList'
                        }]
                    }).show();
    			}
    		}
        },{
            header: '专题班 ',
            dataIndex: 'ztbHour',
            renderer: function(value, metaData, record){
            	if(value!=0)
            		metaData.style = "white-space:normal;cursor: pointer;color:blue;";
            	metaData.tdAttr = "data-qtip='" + value + 
    			"' hourYear=" + record.get("hourYear");
                return value;
            },
            listeners: {
    			click: function(g, clm){
    				var hourYear = clm.getAttribute("hourYear");
    				var params=g.up().store.proxy.extraParams;
    				Ext.create('AM.default.DefaultWindowView', {
                        title: "查看班级列表",
                        hourYear:hourYear,
                        params:params,
                        searchClassType:'ztb',
                       	width: 1000,
                        height: 450,
                        items: [{
                        	xtype: 'myPersonalFilesClassList'
                        }]
                    }).show();
    			}
    		}
        }, /*{
            header: '发布状态',
            dataIndex: 'tc.publish_State',
            width: 70,
            renderer: function(value, meta, record){
                if(value==2){
                	return '<span style="color:red;">' + '未发布' + '</span>';
                 }else if(value==1){
                	 return '<span style="color:green;">' + '已发布' + '</span>';
                 }
              }
        },*/{
            header: '其他',
            dataIndex: 'qitHour',
            renderer: function(value, metaData, record){
            	if(value!=0)
            		metaData.style = "white-space:normal;cursor: pointer;color:blue;";
            	metaData.tdAttr = "data-qtip='" + value + 
    			"' hourYear=" + record.get("hourYear");
                return value;
            },
            listeners: {
    			click: function(g, clm){
    				var hourYear = clm.getAttribute("hourYear");
    				var params=g.up().store.proxy.extraParams;
    				Ext.create('AM.default.DefaultWindowView', {
                        title: "查看班级列表",
                        hourYear:hourYear,
                        params:params,
                        searchClassType:'qit',
                       	width: 1000,
                        height: 450,
                        items: [{
                        	xtype: 'myPersonalFilesClassList'
                        }]
                    }).show();
    			}
    		}
        },{
            header: '在线学时',
            dataIndex: 'zxHour'
        },{
            header: '在线折算学时',
            dataIndex: 'zxZsHour'
        },{
            header: '合计',
            dataIndex: 'hours'
        }];
        me.store = Ext.create('PJ.' + prototype + '.myPersonalFiles.List', {
            isLoad: false
        });
        me.loadType = gj_onlineLearning_constant.loadType;
        me.callParent(arguments);
    },
    /**
     * 导出
     */
    onExportClick: function(num){
    	var me = this;
    	var store = me.getStore();
    	var params=store.proxy.extraParams;
    	var records = me.getSelectionModel().getSelection();
    	var str = "";
    	for(var i = 0;i<records.length;i++){
    		str += "&searchClassIds=" + records[i].get("classId");
    	}
    	var href=store.exportUrl + "?" + str + '&auditingState=1&clickSource=1';
    	for(var param in params){
    		if(params[param] === undefined){
    			href+="&"+param+"=";
    		}else{
    			href+="&"+param+"="+params[param];
    		}
    	}
    	href+="&expState="+num+"&searchSignUpState=1&searchSignUpState=5";
    	href = encodeURI(href);
    	var atag = Ext.get("exportResume");
    	atag.set({
    		"href": href
    	});
    	atag.dom.click();
    },
    startDate:function(){
    	var dateStr=new Date();
//		return (dateStr.getFullYear()-5)+'-'+(dateStr.getMonth()+1)+'-'+(dateStr.getDate()-1);
		return (dateStr.getFullYear()-5)+'-01-01';
	},
    listeners: {
        //点击列表数据时显示按钮事件
//    	selectionchange: function(selModel, selected){
//    		this.down('#' + this.oldId + "RegistrationAdjustment").setDisabled(selected.length === 0);//报名
//    		this.down('#' + this.oldId + "ApplicationAudit").setDisabled(selected.length === 0);//报名审核
    		//this.down('#' + this.oldId + "Export").setDisabled(selected.length === 0);//导出
//    		this.down('#' + this.oldId + "ViewSignup").setDisabled(selected.length === 0);//查看报名状态
    		//this.down('#' + this.oldId + "AdjustTheQuota").setDisabled(selected.length === 0);//调整名额
//    		this.down('#' + this.oldId + "EntryList").setDisabled(selected.length === 0);//导出培训班报名名单
//    	},
        viewready: function(){
        	var me = this;
        	//导出按钮集合
        	var exportMenu = Ext.create('Ext.menu.Menu', {
                items: [{
                    text: '全部报名名单',
	        		iconCls: 'entryListAllIco',
                    listeners: {
                        click: function(btn){
                        	me.onExportClick(1);
                    	}
                    }
                }, {
                    text: '培训班报名名单',
	        		iconCls: 'entryListIco',
	        		disabled: true,
	        		itemId: this.oldId + "EntryList",
                    listeners: {
                    	click: function(btn){
                    		me.onExportClick(2);
                    	}
                    }
                }]
            });
            this.addDocked([{
                dock: 'top',
                xtype: "searchform",
                columnCount: 3,
                fieldDefaults: {
                    xtype: "combo",
                    emptyText: "请选择",
                    editable: false,
                    queryMode: 'local',//'remote',//数据类型
                    valueField: 'value',
                    displayField: 'text',
                    labelAlign: 'right',
                    labelWidth: 80,
                    maxLength: 100
                },
                items: [{
                    fieldLabel: "年份",
                    name: "searchYear",
                    store: Ext.create("Ext.data.ArrayStore", {
    					fields: ['value', 'text'],
    					data: [[2012, '2012'], [2013, '2013'], [2014, '2014'], [2015, '2015'], [2016, '2016'], [2017, '2017'], [2018, '2018']]
    				})
                }],
                grid: this
            },{
                xtype: 'toolbar',
                dock: 'top',
                displayInfo: true,
                items: [/*{
                    text: '报名审核',
                    iconCls: 'applicationAuditIco',
                    itemId: this.oldId + "ApplicationAudit",
                    disabled: true,
                    scope: this,
                    handler: this.onApplicationAuditClick
                }, '-', {
                    text: '查看报名通过人员',
                    iconCls: 'applicationAuditIco',
                    itemId: this.oldId + "ViewSignup",
                    disabled: true,
                    scope: this,
                    handler: this.onViewSignupStatus
                }, "-",{
                    text: '调整名额',
                    iconCls: 'adjustTheQuotaIco',
                    itemId: this.oldId + "AdjustTheQuota",
                    disabled: true,
                    scope: this,
                    handler: this.onAdjustTheQuotaClick
                }, '-', {
                    text: '代报名',
                    iconCls: 'registrationAdjustmentIco',
                    itemId: this.oldId + "RegistrationAdjustment",
                    disabled: true,
                    scope: this,
                    handler: this.onRegistrationAdjustmentClick
                },'-',*//*{
                    text: '导出',
                	xtype: 'button',
                    cls: 'floater',
                    textAlign: 'right',
                    arrowAlign: 'right',
                    itemId: this.oldId + 'Export',
                    enableToggle: true,
                    iconAlign: 'left',
                    iconCls: 'deriveIco',
                    pressedCls: 'x-btn-focus',
                    menuActiveCls: 'x-btn-menu-active',
                    menu: exportMenu
				},'-', */{
                    xtype: 'label',
                    html: '<span style="color:red">注：合计=中组部调训、主体、境外、专题、其他、在线学习折算。默认统计起始日期为 '+this.startDate()+'。</span>'
                }/*, "->", "->", this.countSelectPanel*/]
            }]);
            // 触发权限过滤事件
            this.fireEvent("permission", this);
            var store = this.store;
            var params = store.proxy.extraParams;
            var newParams = {};
            Ext.apply(params, newParams);
            store.isLoad = true;
            store.load();
        },
        afterrender: function(){
            this.loadMask = new Ext.LoadMask(this, {
                msg: "正在加载中,请稍后...."
            });
        }
    }
});
